
module.exports = function ($scope, $state, $stateParams,$resource,$modal,FileUploader) {
    $scope.company_id = $stateParams.company_id;
    console.log($scope.company_id);
    console.log('上面是company_id')  
    $resource('/api/as/ggc/reviewCompany/findInfo', {}, {}).save({'company_id':$scope.company_id}, function(res){
            console.log(res);
            $scope.a=res.data;
            console.log('上面是企业信息返回值')
               $scope.array = $scope.a.data.split(',');
                    console.log($scope.array);
                    for(var i = 0;i<$scope.array.length;i++){
                        if($scope.array[i]==''){
                            $scope.array.splice(i,1);
                        }
                    }
            if(res.errcode === 0){  
                             
                 
            }else{
                alert(res.errmsg);
           
            }
        });
    $scope.employee={};
    
$scope.ctarr=[
    {name:'王者单位',value:'0'},
    {name:'大师单位',value:'1'},
    {name:'钻石单位',value:'2'},
]
$scope.submit = function(){
    $scope.img = $scope.array.join(",");
    var para = {
        company_id:$scope.company_id,
        company_name:$scope.a.company_name,
        organization_code:$scope.a.organization_code,
        company_type:$scope.a.company_type,
        contact_name:$scope.a.contact_name,
        contact_mobile:$scope.a.contact_mobile,
        contact_email:$scope.a.contact_email,
        data:$scope.img
     }
     if($scope.a.company_name==undefined||$scope.a.company_name==''){
         alert('请填写单位名称');
         return;
     }
     console.log(para);
     $resource('/api/ac/ggc/reviewCompanyService/createCompany', {}, {}).save(para, function(res){
            // console.log(res);
            if(res.errcode === 0){            
                alert('保存成功');
                 $state.go('app.project_list',{});
            }else{
                alert(res.errmsg);
           
            }
        });
}

            //正则判断电话号  
            $scope.checkphone=function(x){
                if(!/^1[34578]\d{9}$/.test(x)) return "您输入的电话号长度或格式错误";
            }
			$scope.showphoneinfo=function(x){
                console.log(x);
                if(x==undefined){
                    $scope.employee.phoneinfo="";
                   return;
                  }
                if(x==''){
                    $scope.employee.phoneinfo="";
                   return;
                  }
                                         
            if($scope.checkphone(x)=="您输入的电话号长度或格式错误"){                
                $scope.employee.phoneinfo="您输入的电话号长度或格式错误"
            }else{
                     $scope.employee.phoneinfo="";
                    }
            }



            $scope.image = function(){
				var para = $state.get('app.imageupload');
				//设置上传文件夹，以自己业务命名
				angular.extend(para, {
					resolve : {  
						'dir' : function(){
							return 't1';
						}
					} 
				})
				console.log(para);
				var modalInstance = $modal.open(para);
				modalInstance.opened.then(function() {// 模态窗口打开之后执行的函数  
					console.log('modal is opened');  
				});  
				modalInstance.result.then(function(result) {  
					console.log(result);  
					$scope.imagearr = JSON.stringify(result);
					// console.log(scope.imagearr);
					$scope.array = result;
                    $scope.a.project_file=$scope.array;
					// $scope.a.project_file = array[0];
					// console.log(scope.info.img);
					// form.result['templete_lock_data_json'] = JSON.stringify(result.lock);
					// form.result['templete_check_data_json'] = result.unlock;

				}, function(reason) {  
					console.log(reason);// 点击空白区域，总会输出backdrop  
					// click，点击取消，则会暑促cancel  
					$log.info('Modal dismissed at: ' + new Date());  
				}); 
			};    

$scope.return=function(){
    $state.go('app.project_list',{});
}

};
